I am comparing two Date fields. Why does DOORS think
12/02/10 22:41:40 is greater than 07/10/11 13:11:38 ?
tlwtheq - Wed Aug 10 13:21:21 EDT 2011 |
|
Re: Date comparison tlwtheq - Wed Aug 10 13:59:06 EDT 2011
Don't get me wrong; I'd still like the answer to my question.
But I got around it by doing intOf(Date d) to get number of seconds
since 1 Jan 1970, 00:00:00 GMT. That worked.
|
|
Re: Date comparison kbmurphy - Wed Aug 10 16:37:53 EDT 2011 tlwtheq - Wed Aug 10 13:59:06 EDT 2011
Don't get me wrong; I'd still like the answer to my question.
But I got around it by doing intOf(Date d) to get number of seconds
since 1 Jan 1970, 00:00:00 GMT. That worked.
Your question belongs in the DXL forum.
Also, without seeing your original code, it's impossible to tell. My guess is that you were comparing strings instead of dates.
Kevin
|
|
Re: Date comparison llandale - Wed Aug 10 16:58:00 EDT 2011 kbmurphy - Wed Aug 10 16:37:53 EDT 2011
Your question belongs in the DXL forum.
Also, without seeing your original code, it's impossible to tell. My guess is that you were comparing strings instead of dates.
Kevin
Yes. She's probably doing this:
... if (dat1 "" < dat2 "")
instead of this:
... if (dat1 < dat2)
|
|
Re: Date comparison tlwtheq - Thu Aug 11 06:59:03 EDT 2011 llandale - Wed Aug 10 16:58:00 EDT 2011
Yes. She's probably doing this:
... if (dat1 "" < dat2 "")
instead of this:
... if (dat1 < dat2)
Nope, I'm not comparing strings, I'mm using real Dates.
|
|
Re: Date comparison llandale - Sun Aug 14 23:24:10 EDT 2011 tlwtheq - Thu Aug 11 06:59:03 EDT 2011
Nope, I'm not comparing strings, I'mm using real Dates.
Post the code.
|
|
Re: Date comparison tlwtheq - Mon Aug 15 10:12:43 EDT 2011 llandale - Sun Aug 14 23:24:10 EDT 2011
Post the code.
Date modDate // As input/specified by user
History h // h.date is Date entry in object history
if (h.date >= modDate) {
....
|
|
Re: Date comparison kbmurphy - Mon Aug 15 11:55:06 EDT 2011 tlwtheq - Mon Aug 15 10:12:43 EDT 2011
Date modDate // As input/specified by user
History h // h.date is Date entry in object history
if (h.date >= modDate) {
....
With DOORS you learn to be very explicit about your variables.
I believe you were comparing a string to a Date.
You code needs to be this instead, and it should work as intended.
Date modDate = "01 Jan 1980"
History h
Object o = current
for h in o do {
Date hDate = h.date
if (hDate >= modDate) {
}
}
I haven't tested this, but I've done a lot of work with history and dates recently, so I'm pretty sure I've got it correct.
|
|
Re: Date comparison tlwtheq - Mon Aug 15 12:10:32 EDT 2011 kbmurphy - Mon Aug 15 11:55:06 EDT 2011
With DOORS you learn to be very explicit about your variables.
I believe you were comparing a string to a Date.
You code needs to be this instead, and it should work as intended.
Date modDate = "01 Jan 1980"
History h
Object o = current
for h in o do {
Date hDate = h.date
if (hDate >= modDate) {
}
}
I haven't tested this, but I've done a lot of work with history and dates recently, so I'm pretty sure I've got it correct.
No, I am not comparing a date to a string.
|
|
Re: Date comparison kbmurphy - Mon Aug 15 15:41:17 EDT 2011 tlwtheq - Mon Aug 15 12:10:32 EDT 2011
No, I am not comparing a date to a string.
According to the code you posted, you were.
h.date returns a string. You must explicitly cast that string to a Date type.
Let me be more clear:
h.date //string
Date hDate = h.date //Date
You were comparing a string to a Date, even though you didn't think you were.
|
|
Re: Date comparison llandale - Mon Aug 15 18:36:07 EDT 2011 kbmurphy - Mon Aug 15 15:41:17 EDT 2011
According to the code you posted, you were.
h.date returns a string. You must explicitly cast that string to a Date type.
Let me be more clear:
h.date //string
Date hDate = h.date //Date
You were comparing a string to a Date, even though you didn't think you were.
This is exactly what I was going to say, except I see these in the doors.exe
... Date ::.(History,HADate_)
... HADate_ date()
... which says "hst.date" is a "Date".
and I don't see any other reference to History and Date together.
Also the following proves us wrong in v9.2.0.1:
void f(string dat)
{ print
"String [" dat
"]\n"
}
void f(Date dat)
{ print
"Date [" dat
"]\n"
}
// replace standard == bool ::==(Date, Date)
{print
"==Date\n";
return(
true)
} History hst Date dat = today()
for hst in (current Module)
do
{ f(hst.date)
// Line A
if (hst.date == today)
// Line B - then print
"Equal\n"
break
// just do one
}... Results are: Date [11/24/10 08:31:51] ==Date Equal
Line A shows that the "Date" version of f() is being called.
Line B shows that the overloaded == is being called which means if (hst.date == today) is comparing two dates.
So, I'm stumped. Perhaps she should add some print statements and see what happens.
|
|
Re: Date comparison kbmurphy - Mon Aug 15 20:23:54 EDT 2011 llandale - Mon Aug 15 18:36:07 EDT 2011
This is exactly what I was going to say, except I see these in the doors.exe
... Date ::.(History,HADate_)
... HADate_ date()
... which says "hst.date" is a "Date".
and I don't see any other reference to History and Date together.
Also the following proves us wrong in v9.2.0.1:
void f(string dat)
{ print
"String [" dat
"]\n"
}
void f(Date dat)
{ print
"Date [" dat
"]\n"
}
// replace standard == bool ::==(Date, Date)
{print
"==Date\n";
return(
true)
} History hst Date dat = today()
for hst in (current Module)
do
{ f(hst.date)
// Line A
if (hst.date == today)
// Line B - then print
"Equal\n"
break
// just do one
}... Results are: Date [11/24/10 08:31:51] ==Date Equal
Line A shows that the "Date" version of f() is being called.
Line B shows that the overloaded == is being called which means if (hst.date == today) is comparing two dates.
So, I'm stumped. Perhaps she should add some print statements and see what happens.
Interesting experiments, Louie!
In replying to her post, I realized she didn't post her actual code in full context. She just starts doing history without a history loop.
My guess is that the snippet she posted isn't what is actually being processed.
To the OP: please post the full context of your code, or another snippet comparing the two dates you compared and were getting the wrong answer on.
Thanks,
Kevin
|
|
Re: Date comparison tlwtheq - Tue Aug 16 07:12:45 EDT 2011 kbmurphy - Mon Aug 15 20:23:54 EDT 2011
Interesting experiments, Louie!
In replying to her post, I realized she didn't post her actual code in full context. She just starts doing history without a history loop.
My guess is that the snippet she posted isn't what is actually being processed.
To the OP: please post the full context of your code, or another snippet comparing the two dates you compared and were getting the wrong answer on.
Thanks,
Kevin
I was going by this definition on the History help panel:
Date property | Extracts
---------------|------------------------
date | date of history record
Regardless, I'm going to stay with the intOf method giving me
a hard integer for comparison, thanks.
>
> Interesting experiments, Louie!
>
> In replying to her post, I realized she didn't post her actual code in full context. She just starts doing history without a history loop.
>
> My guess is that the snippet she posted isn't what is actually being processed.
>
> To the OP: please post the full context of your code, or another snippet comparing the two dates you compared and were getting the wrong answer on.
>
> Thanks,
> Kevin
I was going by this definition on the History help panel:
|
|